
package com.jf.cloud.multishop.listener;

import com.jf.cloud.common.rocketmq.config.RocketMqConstant;
import com.jf.cloud.multishop.service.ShopWalletService;
import org.apache.rocketmq.spring.annotation.RocketMQMessageListener;
import org.apache.rocketmq.spring.core.RocketMQListener;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component;

import java.util.List;

/**
 * @author zz
 */
@Component
@RocketMQMessageListener(topic = RocketMqConstant.ORDER_SETTLED_SHOP_TOPIC,consumerGroup = RocketMqConstant.ORDER_SETTLED_SHOP_TOPIC)
public class OrderReceiptShopConsumer implements RocketMQListener<List<Long>> {

    @Autowired
    private ShopWalletService shopWalletService;

    /**
     * 结束周期完成，结算给商家
     */
    @Override
    public void onMessage(List<Long> orderIds) {
        for (Long orderId : orderIds) {
            shopWalletService.addAmountBySettledOrder(orderId);
        }
    }
}
